package com.suning.sawp.service.impl.maindiscode;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.suning.framework.dal.client.DalClient;
import com.suning.sawp.dto.maindiscode.MainDiscodeDto;
import com.suning.sawp.intf.maindiscode.MainDiscodeService;

/**
 * 
 * 大区映射关系服务实现<br> 
 * 〈功能详细描述〉
 *
 * @author 15050519
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Service
public class MainDiscodeServiceImpl implements MainDiscodeService {

    /**
     * 日志
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(MainDiscodeServiceImpl.class);
    
    /**
     * 数据库操作对象
     */
    @Resource
    DalClient dalClient;
    
    /**
     * 查询所有大区映射关系
     */
    @Override
    public List<MainDiscodeDto> queryMainDiscode() {
        LOGGER.info("queryMainDiscode enter");
        Map<String, Object> queryMap = new HashMap<String, Object>();
        List<MainDiscodeDto> resp = dalClient.queryForList("MAIN_DISCODE.QUERY_ALL", queryMap, MainDiscodeDto.class);
        LOGGER.debug("queryMainDiscode response={}", resp);
        LOGGER.info("queryMainDiscode exit");
        return resp;
    }

    @Override
    public String queryRegion5CdBy8Cd(String region8Code) {
        Map<String, Object> queryMap = new HashMap<String, Object>();
        queryMap.put("region8cd", region8Code);
        String dis8Code = dalClient.queryForObject("MAIN_DISCODE.QUERY_5_CODE_BY_8_CD", queryMap, String.class);
        return dis8Code;
    }

    @Override
    public String queryRegionNameBy8Cd(String region8Code) {
        Map<String, Object> queryMap = new HashMap<String, Object>();
        queryMap.put("region8cd", region8Code);
        String regionName = dalClient.queryForObject("MAIN_DISCODE.QUERY_NAME_BY_8_CD", queryMap, String.class);
        return regionName;
    }

}
